package com.xmjs.baselibrary.view.textview;

import android.content.ClipboardManager;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.EditText;

/**
 * 禁止黏贴的编辑框
 */
public class BanPasteEditText extends EditText {
    private static final int ID_PASTE = android.R.id.paste;

    public BanPasteEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onTextContextMenuItem(int id) {
        if (id == ID_PASTE) {
            ClipboardManager clip = (ClipboardManager) getContext()
                    .getSystemService(Context.CLIPBOARD_SERVICE);
            clip.setText("");
        }
        return super.onTextContextMenuItem(id);
    }
}
